<?php
if( !defined('IN_INDEX') )
{
	die('This page is hidden.');
}

if(!checkSession())
{
			function redirect($url)
			{
			?>
				<script type="text/javascript">
					{
					window.location = "<?=$url?>";
					}
				</script>
			<?php 
			}
			redirect("index.php?action=login");
	exit;
}
include('inc/functions_blog.php');
include('inc/functions_award.php');


$dateformat_long = $CONFIG['date_format_long'];

?>
<table border=1>
<?php
	$userList = getUserList();
	if(mysql_num_rows($userList) > 0){
		$awardList = getAllAward();
		while($user = mysql_fetch_array($userList)){
?>
		<div class="award-list" style="text-align: center; color: red;">
		<?php
			if(mysql_num_rows($awardList) > 0){
				mysql_data_seek($awardList,0);
				$i = 0;
				$awardListStr = "";
				while($awardItem = mysql_fetch_array($awardList)) 
				{
					$result = getAwardOfExercise($user['user_id'], $awardItem);
					if($result){
						if($i == 0){
							$awardListStr .="<table width='100%'>";
						}
						if(is_numeric($result['date']))
						{
							$date = date("m-d-Y", $result['date']);
						}else{
							$date = "";
						}
						if(isset($result['training_id'])){
							$awardListStr .= "<tr><td style='border-bottom: 1px solid;' width=80%><img src='img/award_pic/".$awardItem['image']."'/>".$awardItem['award_name']."</td><td width=20% style='border-bottom: 1px solid;'><a href='index.php?action=profile&sub=show&tid=".$result['training_id']."'>".$date."</a></td></tr>";
						}else{
							$awardListStr .= "<tr><td style='border-bottom: 1px solid;'><img src='img/award_pic/".$awardItem['image']."'/>".$awardItem['award_name']."</td><td style='border-bottom: 1px solid;'>".$date."</td></tr>";
						}
		?>
			<!--
			<div class="award-item" style="margin-top: 15px;">
				<img src="img/award_pic/<?php echo $awardItem['image'] ?>" height="112" width="150"/><br/>
				<span class="award-name"><?php echo $awardItem['award_name']."<br/>"; ?></span>
			</div>
			-->
		<?php
						$i++;
					}
				}
			}
		?>
		</div>
		<?php
		if($awardListStr != ""){
		?>
		<tr><td><?php echo $user['user_firstname']." ".$user['user_lastname']?></td><td><?php echo $awardListStr."</table>"?></td></tr>
		<?php
		}
		?>
		
<?php	
		}
	}
?>
<table>